angular.module('proDetailsModule', [])
    .controller('detailsCtrl', ['$scope','$http','$location', function ($scope,$http,$location) {

        $scope.proData = [];

        $scope.toSearch = function(){
            $location.path("/proSearch");
        }

        $http.get('./admin/details.php',{
            params:{
                getType:'getDetail',
                id : $location.$$search.id
            }
        }).then(function(res){
            $scope.proData = res.data[0];
        });

        $scope.addShopCart = function(){
            $http.post('./admin/details.php',{
                postType:'add',
                id : $scope.proData.id,
                price : $scope.proData.price
            }).then(function(res){
                if(res.data.status == 5){
                    alert("您还未登录");
                }else{
                    if(res.data.status == 1){
                        alert("添加成功");
                    }else{
                        alert("添加失败");
                    }
                }
            });
        }

        $scope.goConfirmOrder = function(){
            $location.path("/confirmOrder").search('id='+$scope.proData.id);
        }
        
        
    }]);

